package ren.steve.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import ren.steve.model.system.bean.SystemUserRole;
import ren.steve.system.mapper.SystemUserRoleMapper;
import ren.steve.system.service.SystemUserRoleService;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: LiuGuoJia
 * @Description:
 * @Date: Created in 2024/1/18 20:04
 */
@Service
public class SystemUserRoleServiceImpl extends ServiceImpl<SystemUserRoleMapper, SystemUserRole> implements SystemUserRoleService {

  @Override
  public List<String> getSystemRoleByUserId(String id) {
    QueryWrapper<SystemUserRole> wrapper = new QueryWrapper<>();
    wrapper.eq("user_id", id);
    wrapper.orderByAsc("user_id");
    List<SystemUserRole> userRoles = baseMapper.selectList(wrapper);
    List<String> ids = new ArrayList<>();
    for (SystemUserRole userRole : userRoles) {
      ids.add(userRole.getRoleId());
    }
    return ids;
  }
}
